class Solution {
public:
    bool isPalindrome(int x) {
        if (x < 0) return false;
        string str;
        str.reserve(50);
        int tmp = x;
        while (tmp > 0) {
            str.push_back(tmp % 10 + '0');
            tmp /= 10;
        }
        int size = str.size() / 2;
        for (int i = 0; i < size; i++) {
            if (str[i] != str[str.size() - i - 1])
                return false;
        }
        return true;
    }
};